<template>
	<view style="padding-top: 20px; background-color: #FFFFFF;">
		<view class="inputmoney">
			<view class="" style="color: rgba(16, 16, 16, 1);
font-size: 48px;
text-align: left;">
				¥
			</view>
			<input type="text" value="" v-model="money" style="color: rgba(16, 16, 16, 1);
font-size: 28px;text-align: left;margin-left: 20px;padding: 10px 0;" disabled placeholder="请选择金额"/>
		</view>
						<!-- <view class="group-name">
							<text class="pd-10" style="margin-left: 20px;">红包模式</text>
							
							<view class="item-name"><switch @change="switch3Change"  :checked="hb_status==1?false:true"/></view>
						</view>
						<text style="margin-left: 20px;color: #DBDBDB;font-size: 14px;">默认余额红包，开启为积分红包</text> -->
		<view class="threetian">

			<view class="a" @click="onemoney(item)" v-for="(item,index) in List" :key="index">

				<text >{{item.k_name}}</text>
				<text>{{item.k_money}}</text>
			</view>
		</view>
		<view style="text-align: center;margin-top: 30px;">
			<!-- 注：<br> -->
			开通游戏&nbsp;&nbsp;零钱充值请联系客服
		</view>
		<view class="btnkaitong" @click="finish">
			开通
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				money:'',
				List:[],
				qid:'',
				timestatus:'',
				status:'',
				roomid:'',
				kj_status:'',
				hb_status:'',
				jifen:'',
				groupName:''
			}
		},
		onLoad(options) {
			this.qid = options.qid
			console.log(this.qid)
			this.status = options.status
			this.roomid = options.roomid
			this.jifen = options.jifen
			this.groupName=options.groupName
			let that =this
			let token = uni.getStorageSync("token")
			uni.request({
				url: this.G_base + '/api/lz/qyxmoney',
				method: 'GET',
				header: {
					'content-type': 'application/x-www-form-urlencoded',
					'Authori-zation': 'Bearer ' + token
				},
				success: res => {
					console.log(res)
					this.List =res.data.data
				}
			})
			let tokenmsg = uni.getStorageSync("token")
			uni.request({
				url: that.G_base + '/api/lz/isqinfo',
				method: 'POST',
				header: {
					'content-type': 'application/x-www-form-urlencoded',
					'Authori-zation': 'Bearer ' + tokenmsg
				},
				data: {
					id: that.qid,
				},
				success: res => {
					console.log(res)
					this.hb_status = res.data.data.hb_status
				}
			})
		},
		methods: {
			test() {
				uni.navigateBack({
					delta: 1
				})
			},
			//获取动态
			hb_stat(){
				let tokenmsg = uni.getStorageSync("token")
				uni.request({
					url: this.G_base + '/api/lz/isqinfo',
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation': 'Bearer ' + tokenmsg
					},
					data: {
						id: this.qid,
					},
					success: res => {
						console.log(res)
						this.hb_status = res.data.data.hb_status
					}
				})
			},
			switch3Change(e){
				if (e.target.value == true) {
					let token = uni.getStorageSync("token")
					uni.request({
						url: this.G_base + '/api/lz/hbstatus',
						method: "POST",
						data: {
							id: this.qid,
							status:2
						},
						header: {
							'content-type': 'application/x-www-form-urlencoded',
							'Authori-zation': 'Bearer ' + token
						},
						success: (res) => {
							console.log(res);
							uni.showToast({
								title:'积分红包开启'
							})
							// this.personList=res.data.data
							console.log("开局状态")
							this.hb_stat()
							uni.navigateBack({
								
							})
						},
						fail: (err) => {
							console.log(err)
						}
					});
				} else {
					let token = uni.getStorageSync("token")
					uni.request({
						url: this.G_base + '/api/lz/hbstatus',
						method: "POST",
						data: {
							id: this.qid,
							status:1
						},
						header: {
							'content-type': 'application/x-www-form-urlencoded',
							'Authori-zation': 'Bearer ' + token
						},
						success: (res) => {
							console.log(res);
							uni.showToast({
								title:'余额红包开启'
							})
							// this.personList=res.data.data
							console.log("关局状态")
							this.hb_stat()
						},
						fail: (err) => {
							console.log(err)
						}
					});
				}
				console.log(e.target.value)
			},
			onemoney(msg){
				this.money=msg.k_money
				this.timestatus = msg.k_day
			},
			finish(){
				if(this.jifen==1){
					let token = uni.getStorageSync("token")
					uni.request({
						url: this.G_base + '/api/lz/qyxstart',
						method: 'POST',
						header: {
							'content-type': 'application/x-www-form-urlencoded',
							'Authori-zation': 'Bearer ' + token
						},
						data: {
							qid:this.qid,
							status:this.status,
							money:this.money,
							timestatus:this.timestatus,
							roomid:this.roomid
						},
						success: res => {
							console.log(res)
							// this.List =res.data.data
							if(res.data.status==200){
								uni.showToast({
									title:"开通成功"
								})
								uni.navigateBack({
									
								})
								// setTimeout(()=>{
								// 	uni.redirectTo({
								// 		url:"../qun/qgz?q_id="+this.qid+'&roomid='+this.roomid+'&groupName='+this.groupName
								// 	})
								// },1500)
							}else{
								uni.showToast({
									title:res.data.msg,
									icon:'none'
								})
							}
						}
					})
				}else{
					let token = uni.getStorageSync("token")
					uni.request({
						url: this.G_base + '/api/lz/qyxstart',
						method: 'POST',
						header: {
							'content-type': 'application/x-www-form-urlencoded',
							'Authori-zation': 'Bearer ' + token
						},
						data: {
							qid:this.qid,
							status:this.status,
							money:this.money,
							timestatus:this.timestatus,
							roomid:this.roomid
						},
						success: res => {
							console.log(res)
							// this.List =res.data.data
							if(res.data.status==200){
								uni.showToast({
									title:"开通成功"
								})
								setTimeout(()=>{
									uni.navigateBack({
										
									})
								},1000)
							}
						}
					})
				}
				
			
			}
			
		},
	}
</script>

<style>
	.group-name {
		width: 99%;
		overflow: hidden;
		height: 40px;
		border-top: 1px solid #fafafa;
		padding: 5px 0 ;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	
	.group-name .item-name {
		float: right;
		margin-right: 10px;
		color: #ccc;
		font-size: 14px;
	}
	
	.btnkaitong{
		color: #FFFFFF;
			background: -webkit-linear-gradient(left,#a00000,#e10004,#a00000);
		margin-top: 70px;
		margin-left: 50%;
		transform: translateX(-50%);
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 40px;
		width: 160px;
		height: 50px;
		line-height: 20px;
		text-align: center;
		
	}
	.threetian .a{
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: wrap;
		line-height: 20px;
		text-align: center;
		border: 1px solid rgba(187, 187, 187, 1);
		width: 40%;
		height: 65px;
		margin: 10px;
	}
	.threetian{
		justify-content: center;
		margin-top: 40px;
 		display: flex;
		align-items: center;
		flex-direction: row;
		flex-wrap: wrap;
	}
	.inputmoney {
		margin-left: 40px;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>
